/*
 * @Author: your name
 * @Date: 2024-06-01 10:58:57
 * @LastEditTime: 2024-06-01 11:12:03
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\452.用最少数量的箭引爆气球.cpp
 */
/*
 * @lc app=leetcode.cn id=452 lang=cpp
 *
 * [452] 用最少数量的箭引爆气球
 */

// @lc code=start
class Solution {
public:
    static bool cmp(vector<int>&a, vector<int>& b){
        return a[0] < b[0]; 
    }
    int findMinArrowShots(vector<vector<int>>& points) {
        int count = 1;
        sort(points.begin(), points.end(), cmp);
        for (int i = 1; i < points.size(); i++){
            if(points[i-1][1] < points[i][0]){
                count++;
            }else{
                points[i][1] = min(points[i][1], points[i-1][1]);
            }
        }
        return count;
    }
};
// @lc code=end

